class_name Card
extends RefCounted

# 卡牌基类
var id: String
var name: String
var description: String
var detailed_description: String  # 详细描述
var cost: int
var card_type: GameData.CardType
var rarity: int  # 0=普通, 1=稀有, 2=史诗, 3=传说
var character: GameData.CharacterType  # 哪个角色可以使用
var image_path: String  # 卡片图片路径
var damage: int = 0  # 伤害值
var block: int = 0   # 护甲值
var effects: Array[String] = []  # 特殊效果列表

func _init(card_id: String, card_name: String, card_desc: String, card_cost: int, type: GameData.CardType, card_rarity: int = 0, character_type: GameData.CharacterType = GameData.CharacterType.XU, image: String = "", damage_val: int = 0, block_val: int = 0):
	id = card_id
	name = card_name
	description = card_desc
	detailed_description = card_desc  # 默认与描述相同
	cost = card_cost
	card_type = type
	rarity = card_rarity
	character = character_type
	image_path = image
	damage = damage_val
	block = block_val

# 卡牌效果，子类重写
func on_play() -> void:
	pass

# 卡牌升级
func upgrade() -> void:
	pass

# 获取卡牌描述（包含升级效果）
func get_description() -> String:
	return description

# 获取详细描述
func get_detailed_description() -> String:
	var desc = detailed_description
	if damage > 0:
		desc += "\n伤害: " + str(damage)
	if block > 0:
		desc += "\n护甲: " + str(block)
	if effects.size() > 0:
		desc += "\n特殊效果: "
		for effect in effects:
			desc += effect + " "
	return desc

# 获取稀有度颜色
func get_rarity_color() -> Color:
	match rarity:
		0: return Color.WHITE      # 普通
		1: return Color.GREEN      # 稀有
		2: return Color.BLUE       # 史诗
		3: return Color.PURPLE     # 传说
		_: return Color.WHITE

# 获取稀有度名称
func get_rarity_name() -> String:
	match rarity:
		0: return "普通"
		1: return "稀有"
		2: return "史诗"
		3: return "传说"
		_: return "未知"

# 创建卡牌副本
func duplicate_card() -> Card:
	return Card.new(id, name, description, cost, card_type, rarity, character)
